<?php

namespace App\Http\Requests\Web;

use Illuminate\Foundation\Http\FormRequest;

class EmigratedRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'category_id' => 'required|exists:categories,id,category_group_id,2',
            'subject_id' => 'required|exists:categories,id,category_group_id,1',
            'total' => 'required|integer|gt:0',
            'fraction' => 'required|integer|gte:0|lte:total',
            'redo' => 'filled|string'
        ];
    }

    public function attributes()
    {
       return [
           'category_id' => '分类',
           'subject_id' => '科目',
           'total' => '总题数',
           'fraction' => '我的成绩'
       ];
    }
}
